package com.sea.physical.service.impl;


import com.codecrane.core.util.CountryEnum;
import com.sea.physical.entity.TaxRate;
import com.sea.physical.mapper.TaxRateMapper;
import com.sea.physical.service.TaxRateService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class TaxRateServiceImpl implements TaxRateService {

    @Autowired
    private TaxRateMapper taxRateMapper;

    @Override
    public List<TaxRate> findByCnd(TaxRate taxRate) {
        return taxRateMapper.findByCnd(taxRate);
    }

    @Override
    public int usave(TaxRate taxRate) {
        return taxRateMapper.update(taxRate);
    }

    @Override
    public int delete(Integer id) {
        return taxRateMapper.delete(id);
    }

    @Override
    public int save(TaxRate taxRate) {
        taxRate.setCountryName(CountryEnum.getCountry(taxRate.getCountryCode()));
        return taxRateMapper.insert(taxRate);
    }

    @Override
    public TaxRate findById(Integer id) {
        return taxRateMapper.findById(id);
    }

    @Override
    public TaxRate findByCountryCode(String country, String code) {
        return taxRateMapper.findByCountryCode(country, code);
    }
}
